const express = require('express')
const router = express.Router();
const managerHandler = require('../router_handler/manager.js')
    // 2. 导入需要的验证规则对象
const { reg_adduser_schema, reg_edituser_schema } = require('../schema/manager')
    // 1. 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
router.get('/users', managerHandler.getUsers)
router.post('/users', expressJoi(reg_adduser_schema), managerHandler.addUsers)

//根据用户id查询用户信息
router.get('/users/:id', managerHandler.searchUserById)


//修改用户状态
router.put("/users/:uId/state/:type", managerHandler.changeUserState)


//编辑用户
router.put("/users/:id", expressJoi(reg_edituser_schema), managerHandler.editUserById)


//删除用户
router.delete('/users/:id', managerHandler.deleteUserById)

module.exports = router